package net.jxiny.oschina.synthetical.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.flyco.tablayout.SlidingTabLayout;

import net.jxiny.oschina.R;

import java.util.ArrayList;

import butterknife.BindView;

import butterknife.ButterKnife;
import butterknife.Unbinder;

public class NewsFragment extends Fragment {
    @BindView(R.id.tl_2)
    SlidingTabLayout tab;
    @BindView(R.id.vp)
    ViewPager pager;
    private ArrayList<Fragment>mFragments=new ArrayList<>();
    private final String[] mTitles={
            "关注","软件","资讯","推荐","问答","博客","英文"
    };
    private Unbinder binder;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View view=inflater.inflate(R.layout.fragment_news,container,false);
        binder= ButterKnife.bind(this,view);
        return view;


    }
    @Override
    public void onViewCreated(@NonNull View view,@NonNull Bundle savedInstasceState){
        super.onViewCreated(view,savedInstasceState);
        mFragments.add(new FollowFragment());
        mFragments.add(new SoftwareFragemnt());
        mFragments.add(new InformationFragment());
        mFragments.add(new RecommendFragment());
        mFragments.add(new AnswerFragemnt());
        mFragments.add(new BlogFragment());
        mFragments.add(new EnglishFragment());
        tab.setViewPager(pager,mTitles,getActivity(),mFragments);
    }
    @Override
    public void onDestroyView() {
        super.onDestroyView();
        binder.unbind();
    }
}
